/*
 * @Author: czy
 * @Date: 2021-04-24 08:15:19
 * @LastEditTime: 2021-05-04 09:55:12
 */
#include "mystdio.h"
#include "mystring.h"
#include "mytime.h"

static char format[40] = "%Y/%m/%d %H:%M:%S";

/**
 * @description: Display wall clock.
 */
void showWallClock(void)
{
    char temp[40] = "";
    mystrftime(temp, format, gmtime());
    message(RIGHT, GREEN, temp);
}

// Set WallClock display format.
void setWallClockFormat(char *fmt)
{
    strcpy(format, fmt);
}

// Set WallClock.
void setWallClock(int h, int m, int s)
{
    setTime(h, m, s);
}

// Get WallClock.
void getWallClock(int *h, int *m, int *s)
{
    tm now = gmtime();
    *h = now.tm_hour;
    *m = now.tm_min;
    *s = now.tm_sec;
}

// Set the WallClock refresh period.
void setWallClockRefresh(int interval)
{
    timer(showWallClock, interval);
}
